package br.com.lh.urabuilder.view.properties
{
	import br.com.lh.urabuilder.business.ISelectableComponentsManager;
	import br.com.lh.urabuilder.domain.xml.Option;
	import br.com.lh.urabuilder.model.UraModelLocator;
	
	import mx.binding.utils.BindingUtils;
	import mx.containers.GridItem;
	import mx.containers.GridRow;
	import mx.controls.ComboBox;
	import mx.controls.Image;
	import mx.controls.TextInput;

	[Bindable]
	public class OptionGridRow extends GridRow
	{
		private var option:Option;
		
		public var deleteImage:Image;
		
		
		public function OptionGridRow(option:Option)
		{
			super();
			this.option = option;
			addItens();
			
		}
		
		private function addItens():void{
		
			var item:GridItem = new GridItem();
			var textInput:TextInput = new TextInput();
			item.addChild(textInput); 
			addChild(item);
			if (option !=null && option.pattern != null){
				textInput.text = option.pattern;
			}
			BindingUtils.bindProperty(option,"pattern",textInput,"text");
			
			item = new GridItem();
			var comboBox:ComboBox = new ComboBox();
			var selectableComponentUtils:ISelectableComponentsManager =UraModelLocator.getInstance().selectableComponents;
			comboBox.dataProvider = selectableComponentUtils.getSelectableComponents();
			item.addChild(comboBox); 
			addChild(item);
			if (option !=null && option.nextId != -1){
				comboBox.selectedIndex= option.nextId;
			}
			BindingUtils.bindProperty(option,"nextId",comboBox,"selectedIndex");
			
			item= new GridItem();
			
			deleteImage = new Image();
			deleteImage.source="icons/action_delete.gif";
			deleteImage.buttonMode = true;
			item.addChild(deleteImage); 
			addChild(item);
		}
		
	}
}